from socket import *
from multiprocessing import Process,Queue
def rev(s):
    while True:
        data,addr=s.recvfrom(1024)
        print(data.decode())

def sent(s,addr):
    while True:
        s.sendto(input('请输入信息:').encode(),addr)


def main():
    s=socket(AF_INET,SOCK_DGRAM)
    addr=('127.0.0.1',8090)
    while True:
        a=input('请输入名字:')
        s.sendto(a.encode(),addr)
        if s.recvfrom(1024)[0].decode()=='名字已注册，重新输入':
            print('名字已注册，重新输入')
            continue
        print('输入成功，进入群聊')
        break
    m = Process(target=rev, args=(s, ))
    m.start()
    sent(s,addr)
main()